#
# MDR test suite (Open Watcom wmake)
#
# Build the library first, from the trunk directory:
#   wmake model=c
#
# Then here:
#   wmake
#   wmake model=s
#
# Each t_*.exe tests one module. Pass -a to skip y/n prompts:
#   t_bios.exe
#   t_opl.exe -a
#
# Function coverage inventory (host Python, not DOS):
#   python3 mkcover.py
#

!ifndef model
model = c
!endif

yr = 2026
LIB = ..\mdr$(model)$(yr).lib
CFLAGS = -we -wx -0 -ox -bt=dos -m$(model) -i=..\inc

TESTS = t_bios.exe t_cout.exe t_dos.exe t_mda.exe t_mouse.exe &
        t_opl.exe t_pcx.exe t_pktdrv.exe t_rs232.exe t_sbdigi.exe &
        t_timer.exe t_trig.exe t_unzip.exe t_vid12.exe t_video.exe &
        t_vidx.exe t_wave.exe t_xms.exe

all: .symbolic $(TESTS)

# wcl names the EXE after the first .c file unless -fe is given, so the
# test module must come first and -fe=$^@ pins the output name.
.c.exe: tcommon.c tcommon.h $(LIB)
	wcl $(CFLAGS) -fe=$^@ $(LIB) $*.c tcommon.c

# older ad-hoc programs (not part of the coverage inventory)
legacy: .symbolic dosdat.exe exepath.exe ziplist.exe

dosdat.exe: dosdat.c $(LIB)
	wcl $(CFLAGS) -fe=$^@ $(LIB) dosdat.c

exepath.exe: exepath.c $(LIB)
	wcl $(CFLAGS) -fe=$^@ $(LIB) exepath.c

ziplist.exe: ziplist.c $(LIB)
	wcl $(CFLAGS) -fe=$^@ $(LIB) ziplist.c

clean: .symbolic
	rm -f *.obj *.exe *.err _t_*.tmp
